package day15;

import java.time.DayOfWeek;
import java.time.LocalDate;

//定义枚举
public enum MyEnum {
    //枚举常量可以提供多个，有几个常量最后就会走几种构造方法
    ONE,TWO,THREE;
    private MyEnum(){
        System.out.println("执行了构造方法！");
    } //只能私有构造方法
    String name; //成员变量
    public void test(){} //普通方法
    public static void test2(){} //静态方法

    public static void main(String[] args) {
        //使用：就把枚举当成常量用，相当于走构造方法
        MyEnum my1=MyEnum.ONE;
        MyEnum my2=MyEnum.ONE;
        MyEnum my3=MyEnum.TWO;
        MyEnum my4=MyEnum.TWO;
        MyEnum my5=MyEnum.THREE;
        MyEnum my6=MyEnum.THREE;

    }

}

enum MyEnum2{
    AAA("志广",18),BBB;  //只会调用两次构造
    String name;
    int age;
    private MyEnum2(){
        System.out.println("无参构造");
    }
    private MyEnum2(String name,int age){
        System.out.println("有参构造");
        this.name=name;
        this.age=age;
    }

    public static void main(String[] args) {
        MyEnum2 my1=MyEnum2.AAA;
        MyEnum2 my2=MyEnum2.BBB;
        //枚举如何使用switch
        LocalDate ld=LocalDate.now();
        DayOfWeek dw= ld.getDayOfWeek();
        switch (dw){
            case MONDAY:
                System.out.println("今天是星期一");
                break;
            case TUESDAY:
                System.out.println("今天是星期二");
                break;
            case WEDNESDAY:
                System.out.println("今天是星期三");
                break;
            case THURSDAY:
                System.out.println("今天是星期四");
                break;
            case FRIDAY:
                System.out.println("今天是星期五");
                break;
            case SATURDAY:
                System.out.println("今天是星期六");
                break;
            case SUNDAY:
                System.out.println("今天是星期天");
                break;
        }
    }
}